/*****************************************************************************
 * plum_hal_time.h
 *
 * Copyright (C) 2020 Jeasonvor <1101627719@qq.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/

#ifndef __PLUM_HAL_TIME_H__
#define __PLUM_HAL_TIME_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/*****************************************************************************
 * Public Types
 ****************************************************************************/

typedef enum {
    PLUM_HAL_TIME_MODE_ALARM,  /** 单次定时 **/
    PLUM_HAL_TIME_MODE_PERIOD, /** 周期定时 **/
} plum_hal_time_mode_t;

typedef enum {
    PLUM_HAL_TIME_TYPE_UP,   /** 向上计数 **/
    PLUM_HAL_TIME_TYPE_DOWN, /** 向下计数 **/
} plum_hal_time_type_t;

typedef struct {
    plum_u32             period;
    plum_hal_time_mode_t mode;
    plum_hal_time_type_t type;
    plum_void (*handler)(plum_void *arg);
} plum_hal_time_cof_t;

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/**
 * @brief:  初始化定时器
 *
 * @param[in]:      id      -       定时器ID
 * @param[in]:      config  -       配置参数指针
 *
 * @return: 返回执行状态
 */
plum_s32 plum_hal_time_init(plum_u32 id, plum_hal_time_cof_t *config);

/**
 * @brief:  挂起定时器
 *
 * @param[in]:  id      -   定时器ID
 *
 * @return
 */
plum_void plum_hal_time_suspend(plum_u32 id);

/**
 * @brief:  恢复定时器
 *
 * @param[in]:  id      -   定时器ID
 *
 * @return
 */
plum_void plum_hal_time_resume(plum_u32 id);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_HAL_TIME_H__ */
/****************************************************************************/

/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
